package com.zrz.util;

import com.zrz.wechart.*;


/**
* 类名: MenuManager </br>
* 包名： com.souvc.weixin.main
* 描述:菜单管理器类 </br>
* 发布版本：V1.0  </br>
 */
public class MenuManagerTest {
//	 private static Logger log = LoggerFactory.getLogger(MenuManager.class);

	    public static void main(String[] args) {
	        // 第三方用户唯一凭证
	        String appId = "wx858281d9aff79609";
	        // 第三方用户唯一凭证密钥
	        String appSecret = "c2575b8add176fdbe052e5d14a10235e";

	        // 调用接口获取access_token
	        WeixinOauth2Token at = WeixinUtil.getAccessToken(appId, appSecret);

	        if (null != at) {
	            // 调用接口创建菜单
	            int result = WeixinUtil.createMenu(getMenu(), at.getAccessToken());

	            // 判断菜单创建结果
	            if (0 == result)
//	                log.info("菜单创建成功！");
	            	System.out.print("成功");
	            else
//	                log.info("菜单创建失败，错误码：" + result);
					System.out.print("失败");

	        }
	    }
	private static String url="";
	    private static String appid="";
	    private static  String  secret="";
	    /**
	     * 组装菜单数据
	     *
	     * @return
	     */
	    private static Menu getMenu() {
	        /**
	         * 微信：  mainBtn1,mainBtn2,mainBtn3底部的三个一级菜单。
	         */

	        ComplexButton mainBtn1 = new ComplexButton();
	        mainBtn1.setName("首页");
	        CommonButton btn11 = new CommonButton();
	        //一级下有1个子菜单
	        btn11.setName("会员");
	        btn11.setType("view");
	        btn11.setKey("11");
	        btn11.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx858281d9aff79609&redirect_uri=http://qfm.cctb.tv/&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
//			CommonButton btn12 = new CommonButton();
//			//一级下有1个子菜单
//			btn12.setName("推广");
//			btn12.setType("view");
//			btn12.setKey("11");
//			btn12.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90fa698910b7b66c&redirect_uri=http://1f260a90.ngrok.io/oauth/extension&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
	        mainBtn1.setSub_button(new CommonButton[] {btn11});


//	        ComplexButton mainBtn2 = new ComplexButton();
//	        mainBtn2.setName("我的");
//	        CommonButton btn21 = new CommonButton();
//	        //一级下有1个子菜单
//	        btn21.setName("会员");
//	        btn21.setType("view");
//	        btn21.setKey("21");
//	        btn21.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90fa698910b7b66c&redirect_uri=http://1f260a90.ngrok.io/oauth/member&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
//			CommonButton btn22 = new CommonButton();
//			//一级下有1个子菜单
//			btn22.setName("我的");
//			btn22.setType("view");
//			btn22.setKey("21");
//			btn22.setUrl("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx90fa698910b7b66c&redirect_uri=http://1f260a90.ngrok.io/oauth/mine&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect");
//	        mainBtn2.setSub_button(new CommonButton[] {btn21,btn22});


//	        ComplexButton mainBtn3 = new ComplexButton();
//	        mainBtn3.setName("我的");
//	        CommonButton btn32 = new CommonButton();
//	        btn32.setName("我的信息");
//	        btn32.setType("view");
//	        btn32.setKey("32");
//	        btn32.setUrl("http://app1.zhao8.com/account");
//	        CommonButton btn33 = new CommonButton();
//	        btn33.setName("我的订阅");
//	        btn33.setType("view");
//	        btn33.setKey("33");
//	        btn33.setUrl("http://app1.zhao8.com/");
//	        CommonButton btn34 = new CommonButton();
//	        btn34.setName("公司公告");
//	        btn34.setType("view");
//	        btn34.setKey("34");
//	        btn34.setUrl("http://app1.zhao8.com");
//	        mainBtn3.setSub_button(new CommonButton[] {btn32, btn33,btn34 });

	        /**
	         * 封装整个菜单
	         */
	        Menu menu = new Menu();
	        menu.setButton(new Button[] {mainBtn1 });

	        return menu;
	    }
}
